﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
public partial class aspnet_admin_bock_Gbook_CX_GBook_Edit : System.Web.UI.Page
{
    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();


    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();


    /// <summary>
    /// id
    /// </summary>
    string id = "";
    public string Cid = "";
    protected void Page_Load(object sender, EventArgs e)
    {

        if (IsPostBack)
        {
            try
            {
                id = Request.QueryString["id"].Trim();

                PageSave(int.Parse(id));
            }
            catch
            {
                Response.Write("");
            }
        }

            Page.Title = "留言修改查看";

            PageLand_First();

            
       

    }

    /// <summary>
    /// 加载时出现的东东
    /// </summary>
    protected void PageLand_First()
    {


        try
        {
            id = Request.QueryString["id"].Trim();
            int.Parse(id);
            MyDt = TextData.SqlataSet("select * from [CX_Gbook] where CX_Gbook_id=" + id + "").Tables[0];


            CX_Gbook_Name.Text = MyDt.Rows[0]["CX_Gbook_Name"].ToString().Trim();
            CX_Gbook_Creater.Text = MyDt.Rows[0]["CX_Gbook_Creater"].ToString().Trim();
            CX_Gbook_Doctor.Text = MyDt.Rows[0]["CX_Gbook_Doctor"].ToString().Trim();
            CX_Gbook_From.Text = MyDt.Rows[0]["CX_Gbook_From"].ToString().Trim();
            CX_Gbook_Address.Text = MyDt.Rows[0]["CX_Gbook_Address"].ToString().Trim();
            CX_Gbook_Tel.Text = MyDt.Rows[0]["CX_Gbook_Tel"].ToString().Trim();
            CX_Gbook_QQ.Text = MyDt.Rows[0]["CX_Gbook_QQ"].ToString().Trim();
            CX_Gbook_Email.Text = MyDt.Rows[0]["CX_Gbook_Email"].ToString().Trim();
            CX_Gbook_Sex.Text = MyDt.Rows[0]["CX_Gbook_Sex"].ToString().Trim();
            CX_Gbook_lx.Text = MyDt.Rows[0]["CX_Gbook_lx"].ToString().Trim();
            CX_Gbook_IP.Text = MyDt.Rows[0]["CX_Gbook_IP"].ToString().Trim();
            CX_Gbook_PublicTime.Text = MyDt.Rows[0]["CX_Gbook_PublicTime"].ToString().Trim();
            CX_Gbook_Cont.Text = MyDt.Rows[0]["CX_Gbook_Cont"].ToString().Trim();
            CX_Gbook_Sort.Text = MyDt.Rows[0]["CX_Gbook_Sort"].ToString().Trim();
            CX_Gbook_ContRe.Text = MyDt.Rows[0]["CX_Gbook_ContRe"].ToString().Trim();


        }
        catch
        {
            MyDt = TextData.SqlataSet("select * from [CX_Gbook]  ").Tables[0];
            CX_Gbook_Name.Text = MyDt.Rows[0]["CX_Gbook_Name"].ToString().Trim();
            CX_Gbook_Creater.Text = MyDt.Rows[0]["CX_Gbook_Creater"].ToString().Trim();
            CX_Gbook_Doctor.Text = MyDt.Rows[0]["CX_Gbook_Doctor"].ToString().Trim();
            CX_Gbook_From.Text = MyDt.Rows[0]["CX_Gbook_From"].ToString().Trim();
            CX_Gbook_Address.Text = MyDt.Rows[0]["CX_Gbook_Address"].ToString().Trim();
            CX_Gbook_Tel.Text = MyDt.Rows[0]["CX_Gbook_Tel"].ToString().Trim();
            CX_Gbook_QQ.Text = MyDt.Rows[0]["CX_Gbook_QQ"].ToString().Trim();
            CX_Gbook_Email.Text = MyDt.Rows[0]["CX_Gbook_Email"].ToString().Trim();
            CX_Gbook_Sex.Text = MyDt.Rows[0]["CX_Gbook_Sex"].ToString().Trim();
            CX_Gbook_lx.Text = MyDt.Rows[0]["CX_Gbook_lx"].ToString().Trim();
            CX_Gbook_IP.Text = MyDt.Rows[0]["CX_Gbook_IP"].ToString().Trim();
            CX_Gbook_PublicTime.Text = MyDt.Rows[0]["CX_Gbook_PublicTime"].ToString().Trim();
            CX_Gbook_Cont.Text = MyDt.Rows[0]["CX_Gbook_Cont"].ToString().Trim();
            CX_Gbook_ContRe.Text = MyDt.Rows[0]["CX_Gbook_ContRe"].ToString().Trim();
            CX_Gbook_Sort.Text = MyDt.Rows[0]["CX_Gbook_Sort"].ToString().Trim();
        }
    }


    protected void PageSave(int id)
    {


        try
        {

            if (CX_Gbook_Cont.Text != "" && CX_Gbook_Name.Text.Length < 250 && CX_Gbook_ContRe.Text.Length < 25000 && int.Parse(CX_Gbook_Sort.Text.Trim()) <= 99999)
            {
			
			string sql ="";
            sql = "UPDATE [CX_Gbook]\r\n" +
                "SET \r\n" +
                "[CX_Gbook_Cont] = '" + CX_Gbook_Cont.Text.Trim() + "'\r\n" +
                ",[CX_Gbook_Sort] ='" + CX_Gbook_Sort.Text.Trim() + "'\r\n" +
                ",[CX_Gbook_ContRe] = '" + CX_Gbook_ContRe.Text.Trim() + "'\r\n" +
                "WHERE [CX_Gbook_id] = " + id + "";
             //Response.Write(sql);

              TextData.SqlDataSave(sql);

            tt.Text = "回复成功" + CX_Gbook_Name.Text + "成功";


            }
            else
            {
                tt.Text = "输入的回复为空或超过250个或不存在此关键字";

            }
        }
        catch
        {
            tt.Text = "更新不能执行";
        }


    }
}
